feat: adding start() method to common client sdk package#1244
Conversation
|
@launchdarkly/js-sdk-common size report |
|
@launchdarkly/browser size report |
1a440b9 to
d249ad8
Compare
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/js-client-sdk-common size report |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit d249ad8. Configure here.
d249ad8 to
8f1e564
Compare
| * When true, the SDK requires `start()` to be called before `identify()`. | ||
| * Set this value to `true` to use the new initialization pattern. | ||
| */ | ||
| requiresStart?: boolean; |
There was a problem hiding this comment.
added this to compat react native... this was the only way I found that would leave RN alone
8f1e564 to
111c7e2
Compare
66673ed to
8b2405c
Compare
ad291be to
0af525e
Compare
| const bootstrapModule = await import('@launchdarkly/js-client-sdk-common'); | ||
| const readFlagsFromBootstrapSpy = jest.spyOn(bootstrapModule, 'readFlagsFromBootstrap'); | ||
|
|
||
| it('parses bootstrap data when start is called with bootstrap', async () => { |
There was a problem hiding this comment.
This makes me assume it parses it more than once? Which actually I think was already true? Once synchronously and again during the identify process? But what behavior change is this test change for?
There was a problem hiding this comment.
This test should have been moved to the shared instance. I think the reason the test changed in this way is that there is no longer a way to test that behavior on this level.
| } | ||
|
|
||
| let effectiveOptions = identifyOptions; | ||
| if (this._requiresStart && identifyOptions?.sheddable === undefined) { |
There was a problem hiding this comment.
I don't know that I like coupling of the default shedding behavior to the _requiresStart behavior.
There was a problem hiding this comment.
okay - yea I got a little too ambitious with trying to change the common default option to be sheddable.
There was a problem hiding this comment.
so for this one, I decided to revert to the old defaults (sheddable is false) and have the browser and electron override that (which is what they did before)
| * Sets the initial context for the client. This must be called before `start()`. | ||
| * @param context The initial context. | ||
| */ | ||
| setInitialContext(context: LDContext): void { |
There was a problem hiding this comment.
Needs to be protected. React directly exposes the inheritance.
There was a problem hiding this comment.
This may present somewhat of a problem to the approach. So maybe we can figure out another approach.
There was a problem hiding this comment.
for this, I decided to get rid of this function altogether and introduced a new internal option that is initialContext
51c47b1 to
1284889
Compare
1284889 to
8289496
Compare
Co-authored-by: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
8289496 to
5cf93ab
Compare
5cf93ab to
e3c5cc7
Compare
39e0210 to
289e6fa
Compare
🤖 I have created a release *beep* *boop* --- <details><summary>browser: 0.1.15</summary> ## [0.1.15](browser-v0.1.14...browser-v0.1.15) (2026-04-17) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk bumped from 4.5.0 to 4.6.0 </details> <details><summary>browser-telemetry: 1.0.31</summary> ## [1.0.31](browser-telemetry-v1.0.30...browser-telemetry-v1.0.31) (2026-04-17) ### Dependencies * The following workspace dependencies were updated * devDependencies * @launchdarkly/js-client-sdk bumped from 4.5.0 to 4.6.0 </details> <details><summary>cloudflare-server-sdk: 2.7.19</summary> ## [2.7.19](cloudflare-server-sdk-v2.7.18...cloudflare-server-sdk-v2.7.19) (2026-04-17) ### Bug Fixes * remove `rollup-plugin-dts` dependency ([#1288](#1288)) ([ea64b82](ea64b82)) </details> <details><summary>jest: 1.0.10</summary> ## [1.0.10](jest-v1.0.9...jest-v1.0.10) (2026-04-17) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/react-native-client-sdk bumped from ~10.15.2 to ~10.16.0 </details> <details><summary>js-client-sdk: 4.6.0</summary> ## [4.6.0](js-client-sdk-v4.5.0...js-client-sdk-v4.6.0) (2026-04-17) ### Features * adding start() method to common client sdk package ([#1244](#1244)) ([7f5f468](7f5f468)) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk-common bumped from 1.24.0 to 1.25.0 </details> <details><summary>js-client-sdk-common: 1.25.0</summary> ## [1.25.0](js-client-sdk-common-v1.24.0...js-client-sdk-common-v1.25.0) (2026-04-17) ### Features * Add experimental FDv2 support for React Native. ([#1243](#1243)) ([7ed2c08](7ed2c08)) * adding start() method to common client sdk package ([#1244](#1244)) ([7f5f468](7f5f468)) ### Bug Fixes * FDv2 -- cache initializer returns transfer-none on cache miss ([#1275](#1275)) ([7bf3c31](7bf3c31)) </details> <details><summary>react-native-client-sdk: 10.16.0</summary> ## [10.16.0](react-native-client-sdk-v10.15.2...react-native-client-sdk-v10.16.0) (2026-04-17) ### Features * Add experimental FDv2 support for React Native. ([#1243](#1243)) ([7ed2c08](7ed2c08)) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk-common bumped from 1.24.0 to 1.25.0 </details> <details><summary>react-sdk: 0.2.1</summary> ## [0.2.1](react-sdk-v0.2.0...react-sdk-v0.2.1) (2026-04-17) ### Dependencies * The following workspace dependencies were updated * dependencies * @launchdarkly/js-client-sdk bumped from ^4.5.0 to ^4.6.0 </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Mostly mechanical version/changelog updates, but it publishes new SDK versions (including new/experimental client capabilities) which could affect downstream consumers if the release contents are incorrect. > > **Overview** > Updates release metadata for a multi-package publish, bumping versions across the Browser, React Native, React, Cloudflare, combined-browser, browser-telemetry, and jest packages and updating their changelogs and example app dependencies accordingly. > > Also updates embedded `x-release-please-version` strings (for SDK/wrapper reporting) to match the new package versions. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d56c92d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This PR will consolidate the
start()method into the shared client sdk package.To do this we also:
requiresStartwhich should betruefor new SDKs (and only RN has it defaultfalse)requiresStartis, effectively, a feature flag for whether the SDK is using the newcreate+startinitialization patternstartmethod into client commonstartmethod out of browser and electron sdksNote
Medium Risk
Touches core initialization/identify behavior across multiple SDKs and changes when bootstrap parsing and goal tracking occur, which could affect startup sequencing and existing integrations if edge cases regress.
Overview
Moves the
start()implementation (including bootstrap flag preloading and init promise caching/timeout behavior) from the Browser and Electron SDKs into the sharedpackages/shared/sdk-clientLDClientImpl.Introduces
LDStartOptionsin the shared API and adds internal optionsrequiresStartandinitialContextso platform SDKs can enforce the new create+start()initialization pattern;identifyResult()now blocks pre-start()calls whenrequiresStartis enabled and updates the logged error message.Updates Browser/Electron wrappers and tests accordingly (Browser/Electron remove their custom
start()logic, Browser ensures goal tracking only starts afterstart()), and adds a consolidatedLDClientImpl.start()test suite in the shared package.Reviewed by Cursor Bugbot for commit 5c9e61f. Bugbot is set up for automated code reviews on this repo. Configure here.